 <template>
  <div class="home">
    <el-container>
      <el-container>
        <!-- header部分 -->
        <el-header>
          <div class="logo">
            <img src="../assets/logo.png" alt>
            <p>海川云谷</p>
          </div>
          <div class="system-title">
            <router-link to="/" class="el-breadcrumb-item">
              <a href="#">首页</a>
            </router-link>
            <router-link to="/Asset" class="el-breadcrumb-item">
              <a href="#">资产</a>
            </router-link>
            <router-link to="/Statistics" class="el-breadcrumb-item">
              <a href="#">统计</a>
            </router-link>
            <router-link to="/Check" class="el-breadcrumb-item">
              <a href="#">盘点</a>
            </router-link>
            <router-link to="/Board" class="el-breadcrumb-item">
              <a href="#">模块</a>
            </router-link>
          </div>
          <div>
            <span class="welcome">您好，{{$store.getters.username}}</span>
            <el-button type="text" @click="logout">退出</el-button>
          </div>
        </el-header>
        <!-- 中间内容部分 -->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
           
<script>
import { getMenus } from "../api/index.js";
export default {
  data() {
    return {
      isCollapse: false,
      menuData: []
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    toggleCollapse() {
      this.isCollapse = !this.isCollapse;
    },
    logout() {
      // 1. 清除登录状态，即删除保存在localStorage中的token
      localStorage.removeItem("mytoken");
      // 2. 跳转到登录页面
      this.$router.push({ name: "Login" });
    }
  },
  created() {
    getMenus().then(res => {
      if (res.meta.status === 200) {
        this.menuData = res.data;
      }
    });
  }
};
</script>
<style lang="scss" scoped>
.home {
  height: 100%;
  .el-menu-admin:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
  .el-container {
    height: 100%;
    padding: 0;
  }
  .el-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
  }
  .el-breadcrumb-item {
    width: 108px;
    height: 50px;
    color: #ccc;
    font-size: 16px;
    line-height: 28px;
  }
  a {
    text-align: center;
    line-height: 50px;
    display: inline-block;
    &:hover {
      background-color: #48c9b0;
    }
  }
  .logo {
    width: 30px;
    height: 50px;
    position: relative;
    background-color: #fff;
    img {
      position: absolute;
      height: 40px;
      width: 43px;
      left: 10px;
      top: 10px;
    }
    p {
      display: inline-block;
      position: absolute;
      width: 73px;
      height: 25px;
      left: 60px;
      top: 33px;
      font-family: "Arial-BoldMT", "Arial Bold", "Arial";
      font-weight: 700;
      font-style: normal;
      color: #ff9900;
    }
  }
  .system-title {
    font-size: 20px;
    color: #fff;
    padding: 0 50px;
  }
  .logout-btn {
    color: orange;
  }
  .welcome {
    color: #ccc;
  }
}
</style>



